import { request } from "@/utils/http";
import {
  HospitalList,
  Province,
  BookingSchedule,
  DoctorList,
} from "./model/types";

//获取省的数据
export const getProvince = () =>
  request.get<any, Province>("/admin/cmn/dict/findByDictCode/province");

//获取市的数据
export const getCity = (provinceId: string) =>
  request.get<any, Province>(`/admin/cmn/dict/findByParentId/${provinceId}`);

//获取区的数据

export const getArea = (cityId: string) =>
  request.get<any, Province>(`/admin/cmn/dict/findByParentId/${cityId}`);

//获取医院类型的数据

export const getHospitalType = (id: string) =>
  request.get<any, Province>(`/admin/cmn/dict/findByParentId/${id}`);

//获取医院列表的数据
export const getHospitalList = (
  page: number,
  limit: number,
  data?: {
    hoscode?: string;
    hosname?: string;
    hostype?: number;
    provinceCode?: string;
    cityCode?: string;
    disTrictCode?: string;
    status?: string;
  }
) =>
  request.get<any, HospitalList>(`/admin/hosp/hospital/${page}/${limit}`, {
    params: data,
  });

//获取医院详情
export const getBaseHospitalInfo = (id: string) =>
  request.get<any, any>(`/admin/hosp/hospital/show/${id}`);

//更新上线状态
export const updateStatus = (id: string, status: number) =>
  request.get<any, null>(`/admin/hosp/hospital/updateStatus/${id}/${status}`);

//获取排班门诊数据
export const getDepartmentInfo = (id: string) =>
  request.get<any, any>(`/admin/hosp/department/${id}`);

//获取排班门诊日期
export const getScheduleRule = (
  page: number,
  limit: number,
  hoscode: string,
  depcode: string
) =>
  request.get<any, BookingSchedule>(
    `/admin/hosp/schedule/getScheduleRule/${page}/${limit}/${hoscode}/${depcode}`
  );

//获取排班详细列表
export const getFindScheduleList = (
  hoscode: string,
  depcode: string,
  workDate: string
) =>
  request.get<any, DoctorList>(
    `/admin/hosp/schedule/findScheduleList/${hoscode}/${depcode}/${workDate}`
  );
